<template>
  <el-dialog
    :title="title"
    :visible.sync="open"
    :before-close="cancel"
    width="800px"
    append-to-body
  >
    <el-form ref="form" :model="form" :rules="rules" class="dialog-form">
      <el-form-item label="智能体名称" prop="key">
        <el-input v-model="form.key" placeholder="请输入智能体名称" />
      </el-form-item>
      <el-form-item label="助手名称" prop="key">
        <el-input v-model="form.key" placeholder="请输入助手名称" />
      </el-form-item>
      <el-form-item label="对话语言及音色" prop="key">
        <cy-try v-model="form.key" filterable :data="list" multiple />
      </el-form-item>
      <el-form-item label="" prop="key">
        <div class="intell-txt">
          <label>角色介绍</label> <el-button type="text">✨ AI一键优化</el-button>
        </div>
        <el-input
          v-model="form.key"
          type="textarea"
          maxLength="200"
          placeholder="请输入角色介绍"
        />
      </el-form-item>

      <el-form-item label="语言模型" prop="key">
        <el-select v-model="form.key" placeholder="请选择语言模型">
          <el-option v-for="i in 3" :key="i" :label="i" :value="i" />
        </el-select>
      </el-form-item>
      <el-collapse class="intel-collapse" v-model="activeNames" @change="handleChange">
        <el-collapse-item name="1">
          <template slot="title"> 高级设置 </template>
          <el-form-item label="角色语速" prop="key">
            <el-select v-model="form.key" placeholder="请选择角色语速">
              <el-option v-for="i in 3" :key="i" :label="i" :value="i" />
            </el-select>
          </el-form-item>

          <el-form-item label="语音识别速度" prop="key">
            <el-select v-model="form.key" placeholder="请选择语音识别速度">
              <el-option v-for="i in 3" :key="i" :label="i" :value="i" />
            </el-select>
          </el-form-item>

          <el-form-item label="角色音调" class="intell-slide-item" prop="key">
            <div class="intell-slider">
              <el-slider class="slider" v-model="form.key" :step="1" :min="-2" :max="2" />
            </div>
          </el-form-item>
        </el-collapse-item>
      </el-collapse>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import cyTry from "./cy-try";
export default {
  props: {
    open: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      form: {},
      rules: {
        key: [{ required: true, trigger: "blur", message: "开发板ID不能为空" }],
      },
      activeNames: [],
      list: [
        {
          label: "系统",
          id: 1,
          children: [
            { label: "用户", id: 2 },
            { label: "用户组", id: 3 },
            { label: "角色", id: 4 },
            { label: "菜单", id: 5 },
            { label: "组织架构", id: 6 },
          ],
        },
        {
          label: "商品",
          id: 7,
          children: [
            { label: "列表", id: 8 },
            { label: "添加", id: 9 },
            { label: "修改", id: 10 },
            { label: "删除", id: 11 },
            { label: "商品分类", id: 12 },
            { label: "分类修改", id: 13 },
          ],
        },
      ],
    };
  },
  components: {
    cyTry,
  },
  methods: {
    cancel() {
      const { item } = this;
      this.$emit("cancel", item);
    },
    resetFormFun() {
      this.form = {};
      this.resetForm("form");
    },
    submitForm() {
      this.$emit("submitForm");
    },
    handleChange(val) {
      console.log(val);
    },
  },
};
</script>

<style scoped lang="scss">
.intell-slider {
  display: flex;
  .slider {
    max-width: 300px;
    width: 100%;
  }
}
.intell-txt {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
</style>
<style>
.intel-collapse,
.intel-collapse .el-collapse-item__header {
  border-bottom: none;
  border-top: none;
}
.intel-collapse .el-collapse-item__header {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.intel-collapse .el-collapse-item__arrow {
  margin: 0 10px;
}
.intell-slide-item label {
  float: none;
}
</style>
